import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Login',
    meta:{
      title:"登录"
    },
    // redirect:"/index",
    component: ()=>import("../views/Login.vue")
  },
  {
    path:"/index",
    name:"Index",
    redirect:"/index/goodstype",
    component:()=>import("../views/Index.vue"),
    children:[//嵌套
    {
      path:"loopimg",//  轮播图
      name:"Loopimg",
      meta:{
        title:"轮播图配置"
      },
      component:()=>import("../views/Indexset/Loopimg.vue")
    },
    {
          path:"hotgoods",//  热销商品
          name:"Hotgoods",
          meta:{
            title:"热销商品"
          },
          component:()=>import("../views/Indexset/Hotgoods.vue")
    },

    {//商品分类
         path:"goodstype",
         name:"Goodstype", 
           meta:{
            title:"商品分类"
          },
         component:()=>import("../views/moduleset/Goodstype.vue")
    },
    {//商品列表
      path:"goodslist",
      name:"Goodslist",
        meta:{
            title:"商品列表"
          },
      component:()=>import("../views/moduleset/Gooslist.vue")
    },
    {
        path:"addgoods",
        name:"Addgoods",
        meta:{
            title:"添加商品"
          },
      component:()=>import("../views/dashboard/Addgoods.vue")
    },
    {
        path:"vipmanger",
        name:"Vipmanger",
        meta:{
            title:"会员管理"
          },
      component:()=>import("../views/moduleset/Vipmanger.vue")
    }
        
    ]
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
router.beforeEach((to,from,next)=>{
      document.title=to.meta.title;
   

     next();
})

export default router
